//防抖
function debounce(fn,time){
    let timer
    return function(){
        clearTimeout(timer); // 重要
        var arg = arguments
        timer = setTimeout(()=>{
            fn.apply(null,arg)
        },time)
    }
}

//节流
function debounce_2(fn,time){
    var timer 
    return function(){
        if (timer) return
        var arg = arguments
        timer = setTimeout(()=>{
            fn.apply(null,arg)
            timer = undefined
        },time)
    }
}